Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Hay un "[" adicional en json, que no se obtiene mediante la respuesta

El Json que obtengo de API getUrl no se ejecuta en mi función Quiero obtener weather.main

 { "coord":{ "lon":88.3697, "lat":22.5697 }, "weather":[ { "id":721, "main":"Haze", "description": "haze", "icon":"50n" } ], "base":"stations", "main":{ "temp":27.97, "feels_like":32.49, "temp_min":27.97, "temp_max":27.97, "pressure":1005, "humidity":83 }, }

Mi Guión =>

 const url = `https://api.openweathermap.org/`; let requete = new XMLHttpRequest(); requete.open('GET', url); requete.responseType = 'json'; requete.send(); requete.onload = function() { if (requete.readyState === XMLHttpRequest.DONE) { if (requete.status === 200) { let reponse = requete.response; let temperatureNow = reponse.main.temp; let summaryNow = reponse.weather.main; let cityCurrent = reponse.name; document.querySelector('#summary').innerText = summaryNow; document.querySelector('#city').innerText = cityCurrent; document.querySelector('#temperature_label').innerText = temperatureNow; } } else { alert('Something went wrong, please come back later.'); } } }

El problema está en resumen Ahora. cityCorriente y temperaturaAhora se están cargando correctamente

 let temperatureNow = reponse.main.temp; let summaryNow = reponse.weather.main; //error let cityCurrent = reponse.name;

Posiblemente me falta "[" de json para que se cargue correctamente en función. Por favor, hágame saber qué mal estoy haciendo.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!